package com.hmh.Entities;

import java.util.List;

public class Blog {
    private int id;
    private String title;
    private Author author;
    private BlogState state;
    private List<Post> posts;

    public Blog() {
    }
    public Blog(Integer id){
        this.id=id.intValue();
    }

    public List<Post> getPosts() {
        return posts;
    }

    public void setPosts(List<Post> posts) {
        this.posts = posts;
    }

    public Blog(int id, String title, Author author, BlogState state, List<Post> posts) {
        this.id = id;
        this.title = title;
        this.author = author;
        this.state = state;
        this.posts=posts;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Author getAuthor() {
        return author;
    }

    public void setAuthor(Author author) {
        this.author = author;
    }

    public BlogState getState() {
        return state;
    }

    public void setState(BlogState state) {
        this.state = state;
    }

    @Override
    public String toString() {
        String block = "  ";
        String result = "id " + getId()+"\n";
        result+= "title is "+getTitle()+"\n";
        result+= "author is "+getAuthor()+"\n";
        result+= "state is "+state.toString()+"\n";
        result+= "posts are ["+"\n";
        if (posts!=null){
            for (Post post:
                    posts) {
                result+= block+post.toString()+"\n";
            }
        }
        result+="]";
        return result;
    }
}
